package cn.lzy.demo;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @Description
 * @Author lzy
 * @Date 2024/1/12 1:33
 * @Version
 **/
public class TestDemo01 {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(JavaConfig.class);

        // ======== 发布事件： =========
        // 方式一：
        MyEvent myEvent = new MyEvent(TestDemo01.class);
        myEvent.setName("小黑");
        myEvent.setGender("男");
        ctx.publishEvent(myEvent);

        System.out.println("==========");

        // 方式二：
        Book book = new Book();
        book.setName("中华上下五千年");
        book.setPrice(100.0);
        ctx.publishEvent(book);

        System.out.println("TestDemo01 >>> Thread.currentThread().getName() = " + Thread.currentThread().getName());

    }
}
